package com.cyl.manager.act.controller;

import java.util.List;

import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;


import com.cyl.manager.act.domain.entity.FhMypunctuation;
import com.cyl.manager.act.domain.convert.FhMypunctuationConvert;
import com.cyl.manager.act.domain.query.FhMypunctuationQuery;
import com.cyl.manager.act.domain.vo.FhMypunctuationVO;
import com.cyl.manager.act.service.FhMypunctuationService;

import com.ruoyi.common.utils.poi.ExcelUtil;
/**
 * 我的标点Controller
 *
 * @author zcc
 * @date 2025-04-25
 */
@Api(description ="我的标点接口列表")
@RestController
@RequestMapping("/act/fhMypunctuation")
public class FhMypunctuationController extends BaseController {
    @Autowired
    private FhMypunctuationService service;
    @Autowired
    private FhMypunctuationConvert convert;

    @ApiOperation("查询我的标点列表")
    @PreAuthorize("@ss.hasPermi('act:fhMypunctuation:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<FhMypunctuation>> list(@RequestBody FhMypunctuationQuery query, Pageable page) {
        List<FhMypunctuation> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

    @ApiOperation("导出我的标点列表")
    @PreAuthorize("@ss.hasPermi('act:fhMypunctuation:export')")
    @Log(title = "我的标点", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public ResponseEntity<String> export(FhMypunctuationQuery query) {
        List<FhMypunctuation> list = service.selectList(query, null);
        ExcelUtil<FhMypunctuationVO> util = new ExcelUtil<>(FhMypunctuationVO.class);
        return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "我的标点数据"));
    }

    @ApiOperation("获取我的标点详细信息")
    @PreAuthorize("@ss.hasPermi('act:fhMypunctuation:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<FhMypunctuation> getInfo(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增我的标点")
    @PreAuthorize("@ss.hasPermi('act:fhMypunctuation:add')")
    @Log(title = "我的标点", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody FhMypunctuation fhMypunctuation) {
        return ResponseEntity.ok(service.insert(fhMypunctuation));
    }

    @ApiOperation("修改我的标点")
    @PreAuthorize("@ss.hasPermi('act:fhMypunctuation:edit')")
    @Log(title = "我的标点", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody FhMypunctuation fhMypunctuation) {
        return ResponseEntity.ok(service.update(fhMypunctuation));
    }

    @ApiOperation("删除我的标点")
    @PreAuthorize("@ss.hasPermi('act:fhMypunctuation:remove')")
    @Log(title = "我的标点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }


    @ApiOperation("钓点审核")
    @PutMapping("/audit")
    public R<String> audit(@RequestBody FhMypunctuation fhMypunctuation) {
        service.audit(fhMypunctuation);
        return R.ok("修改成功");
    }


}
